import React,{useEffect, useState} from 'react'

export default function App() {
  const [n, setn] = useState(0)
  const [nu, setnu] = useState(0)
  const AddNum = ()=>{
    setn(n+1)
  }
  //以下代码属于副作用
  // document.title = `计数器${n}`
  useEffect(()=>{
    document.title = `计数器${n}`
    const span = document.querySelector('span')
    span.textContent =  `计数器${n}`
  },[nu])
  return (
    <div>
      {n}
      <span>{n}</span>
      <button
      onClick={
        AddNum
      }
      >+</button>
    </div>
  )
}
